﻿using System.Web.Mvc;
using Storytelling.Entidades.VTR;
using Storytelling.Modelos.VTR;
using Storytelling.Negocio;
using Storytelling.Utils;
using System.Collections.Generic;

namespace Storytelling.Controllers
{
    public class RitualController : BaseCrudController<Ritual, RitualFormModel>
    {
        protected override IServico<Ritual, RitualFormModel> Servico
        {
            get { return Servicos.Ritual; }
        }

        protected override void EscolherCarregamento(Carga<Ritual> carga, TipoCarregamento tipo)
        {
            carga.Carregar(ent => ent.Disciplina);
        }

        [AutorizarEditor]
        public override ActionResult Form(long? id)
        {
            return base.Form(id);
        }

        [AutorizarEditor]
        public override ActionResult Form(RitualFormModel model)
        {
            return base.Form(model);
        }

        [AutorizarEditor]
        public override ActionResult Excluir(long? id)
        {
            return base.Excluir(id);
        }

        [Authorize]
        public JsonResult CustoExperiencia(long? id, long? idVampiro)
        {
            KeyValuePair<int, KeyValuePair<long, bool>> keyValuePair = new KeyValuePair<int, KeyValuePair<long, bool>>(0, new KeyValuePair<long, bool>(0, false));

            if (id.HasValue && idVampiro.HasValue)
            {
                keyValuePair = Servicos.Vampiro.ComprarRitual(idVampiro.Value, id.Value);
            }

            return Json(new { Nivel = keyValuePair.Key, DisciplinaId = keyValuePair.Value.Key, IsGratis = keyValuePair.Value.Value });
        }
    }
}
